# 除非遍历，未知序列长度
# 

class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

class Solution:
    def middleNode(self, 头: ListNode) -> ListNode:
        慢 = 快 = 头
        while 快 and 快.next:
            慢, 快 = 慢.next, 快.next.next
        return 慢





解 = Solution()
头5 = ListNode(1, ListNode(2, ListNode(3, ListNode(4, ListNode(5)))))
print(解.middleNode(头5).val)
头6 = ListNode(1, ListNode(2, ListNode(3, ListNode(4, ListNode(5, ListNode(6))))))
print(解.middleNode(头6).val)
